package com.loong.zookeeper;


import org.apache.zookeeper.*;

import java.io.IOException;

/**
 * Created by 梁浩峰 on 2016/8/13 11:22.
 */
public class SetConfig {
    public static String url="192.168.83.191:2181;192.168.83.192:2181;192.168.83.193:2181";
    public final static String root="/myconf";

    public final static String urlnode=root+"/url";
    public final static String username=root+"/username";
    public final static String passwd=root+"/passwd";

    private final static String auth_type="digest";
    private final static String auth_passwd="passwd";

    private final static String URLString="10.1.1.1";
    private final static String URLName="passwd";
    private final static String URLPasswd="passwd";


    public static void main(String[] args) throws Exception {
        ZooKeeper zk = new ZooKeeper(url, 3000, new Watcher() {
            public void process(WatchedEvent event) {
                System.out.println("触发了事件"+event.getType());
            }
        });



        if(zk.exists(root,true)==null){
            zk.create(root,root.getBytes(), ZooDefs.Ids.CREATOR_ALL_ACL, CreateMode.PERSISTENT);

        }

        if (zk.exists(urlnode,true)==null){
            zk.create(urlnode,urlnode.getBytes(), ZooDefs.Ids.CREATOR_ALL_ACL, CreateMode.PERSISTENT);
        }
    }




}
